<?php

namespace App\Services;

use App\Models\Hall;
use App\Models\PayVendorScene;
use common\utils\Pack;
use Illuminate\Support\Facades\Log;
use App\Models\HallPartnerConfig;
use App\Models\Money;
use App\Models\MoneyTransfer;
use App\Models\MoneyLog;
use App\Models\MoneyPartner;
use App\Models\MoneyPartnerLog;
use App\Models\MoneyTransferLog;
use App\Models\PartnerUser;
use Illuminate\Support\Facades\DB;
use App\Models\User;
use common\enum\MoneyExchangeEnum;
use common\enum\MoneyLogEnum;
use common\utils\SysCode;

class MoneyDepositService
{
    /**
     * 累计处理支付渠道的日累计， 总累计金额
     * @param $payVendorSceneId 支付场景id
     * @param $amount 区分正负
     */
    public static function handleOnlineDepositLimitAmount($payVendorSceneId, $amount){
        if(empty($payVendorSceneId) || empty($amount)){
            return false;
        }
        $payVendorScend = PayVendorScene::where(['id' => $payVendorSceneId])->first();
        if(empty($payVendorScend)){
            return false;
        }
        $payVendorScend->total_amount += $amount;
        $payVendorScend->day_amount += $amount;
        $payVendorScend->day_amount = $payVendorScend->day_amount < 0 ? 0 : $payVendorScend->day_amount;
        $payVendorScend->total_amount = $payVendorScend->total_amount < 0 ? 0 : $payVendorScend->total_amount;
        return $payVendorScend->save();
    }
}